const BaseIpcHandler = require('../BaseIpcHandler');

class GetDatasetCloudListHandler extends BaseIpcHandler {
    async handle(event, params) {
        // 解析参数
        // console.log('>> GetDatasetCloudListHandler params = ', params);
        const { dataset_supertype, dataset_type } = params;

        // 业务逻辑
        let result = null;
        try {
            const rows = await this.app.datasets_cloud_db.datasets_cloud.getDatasetList(dataset_supertype, dataset_type);
            result = { code: 0, msg: rows };
        } catch (err) {
            console.error('Error get dataset cloud list', err);
            result = { code: -1, msg: err.message };
        }

        // 返回结果
        if (event.from === 'localserver') {
            event.resp.send(result);
        } else {
            return result;
        }
    }
}

module.exports = GetDatasetCloudListHandler;
